<?php
global $Config;
require_once($Config->WebCMSRoot.'Base/Data.mysql.php');

define('_CACHEDURATION', 0); // 3600 - 0: nocache

Class PageData extends db
{
	function PageData()
	{
		parent::db();

		$this->tableName = 'page';
		
		$this->AddMap("ID", "id", "id", DATATYPE_INTEGER, true);
		$this->AddMap("file", "file", "file", DATATYPE_TEXT, true);
		$this->AddMap("cacheCreated", "created", "created", DATATYPE_TIMESTAMP, false);
		$this->AddMap("cacheDuration", "duration", "duration", DATATYPE_INTEGER, false);
	}
  
	function Retrieve(&$page)
	{
//print('<pre>'.var_export($page, true).'</pre>');//exit;
		$sql  = "SELECT ";
		$sql .= $this->GetFieldList();
		$sql .= "FROM " . $this->GetTableName();
		$sql .= $this->GetWhereClause($page);
//print($sql);exit;

		$Voorstelling->Collection = array();

	    $rows = $this->Select($sql);
		if (count($rows) > 0)
	    {
			$row = $rows[0];
			$this->FillRow(&$page, $row);
		}
//print('<pre>'.var_export($page, true).'</pre>');exit;
	}

	function FillRow(&$page, $row)
	{
		parent::FillRow(&$page, &$row);
	}
	
	function GetFieldList()
	{
		parent::GetFieldList(&$select);
		
		return $select;
	}

	function Update(&$page)
	{
//print('<pre>'.var_export($page, true).'</pre>');exit;
		if (isset($page->ID) && !empty($page->ID) && $page->ID != -1)
		{
			$sql  = "UPDATE " . $this->GetTableName(false);
			$sql .= $this->GetUpdateList($page);
			$sql .= "WHERE id=" . $page->ID;
		}
		else
		{
			$sql  = "INSERT INTO " . $this->GetTableName(false);
			$sql .= $this->GetInsertFieldList();
			$sql .= $this->GetInsertValueList(&$page);
		}
//print($sql);exit;

	    $rows = $this->Execute($sql);
	}
}
?>
